﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roy.Entity;
using Roy.IService;
using System.ServiceModel;

namespace Roy.Common.Helper
{
    /// <summary>
    /// 缓存管理辅助类
    /// </summary>
    public static partial class CacheHelper
    {
        #region User

        private static List<User> _AllUser = null;

        public static List<User> AllUser
        {
            get
            {
                return CacheHelper.Get(CacheKeys.AllUser, () => 
                {
                    using (var factory = new ChannelFactory<IRoyUserService>("*"))
                    {
                        var client = factory.CreateChannel();
                        _AllUser = client.GetAllUsers().Contents;
                    }
                    return _AllUser.Count;
                }, ref _AllUser, RoyConfigHelper.CacheTimeOutMinutes);
            }
        }

        #endregion

        #region OtherActionWhenClearAllCache
        
        private static void OtherActionWhenClearAllCache()
        {
            //Other
        }

        #endregion
    }
}
